home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 033a / callerup.zip / CALLERUP.C next >
Text File  |  1991-10-06  |  2KB  |  85 lines

  1. #include <stdio.h>
  2. #include <dir.h>
  3. #include "tools.h"
  4. #include <fcntl.h>
  5.  
  6. typedef struct {
  7.     char date[9];
  8.     char time[9];
  9.     char comment[44];
  10.     char eol[2];
  11. } caller_struct;
  12.  
  13. char *line = "**************************************************************\r\n";
  14. char *space= "                                                                \n";
  15. caller_struct comment;
  16. caller_struct caller_file;
  17. int fd,stat,bflg,eflg,tflg;
  18.  
  19. void set_date_time(void){
  20.     char buffer[15];
  21.     char buffer1[15];
  22.     Get_Date(buffer,'-');
  23.     sprintf(comment.date,"%s ",buffer);
  24.     Get_Time(buffer,':');
  25.     sprintf(comment.time,"(%s)  ",buffer);
  26.     strcpy(comment.eol,"\r\n");
  27. }
  28.  
  29. int process_args(int argcnt, char *args[]){
  30.     char buffer[200]={"\0"};
  31.     int i,a;
  32.     for(i=1;i<argcnt;i++){
  33.         if ((strcmp(args[i],"/B"))==0);
  34.         else if ((strcmp(args[i],"/E"))==0);
  35.         else if ((strcmp(args[i],"/T"))==0);
  36.         else {
  37.             strcat(buffer,args[i]);
  38.             strcat(buffer," ");    }
  39.     }
  40.     strcat(buffer,space);
  41.     if (tflg==1){
  42.         strncpy(comment.date,space,6);
  43.         strncpy(&comment.date[6],buffer,56);
  44.     }else
  45.         strncpy(comment.comment,buffer,44);
  46. }
  47.  
  48. void open_wfile(char *caller){
  49.     int     i;
  50.     struct     ffblk f;
  51.     long     file_pos;
  52.     char     outbuff[80];
  53.     if(findfirst(caller,&f,0)){printf("caller file does not exist!");exit(1);}
  54.     if((fd=_open(caller,O_WRONLY|O_BINARY|O_DENYWRITE))==-1){
  55.         printf("\nError attempting to write %s\a\n",caller);
  56.         exit(1);}
  57.     stat = lseek(fd,f.ff_fsize,SEEK_CUR);
  58.     if(bflg==1)    write(fd,line,sizeof(caller_file));
  59.     write(fd,&comment,sizeof(comment));
  60.     if(eflg==1)    write(fd,line,sizeof(caller_file));
  61.     close(fd);
  62. }
  63.  
  64. void parse_args(int argcnt, char *args[]){
  65.     int i;
  66.     eflg=0;
  67.     bflg=0;
  68.     for(i=1;i<argcnt;i++){
  69.         if((strcmp(args[i],"/B"))==0) bflg=1;
  70.         if((strcmp(args[i],"/E"))==0) eflg=1;
  71.         if((strcmp(args[i],"/T"))==0) tflg=1;
  72.     }
  73. }
  74. main(int argc, char *argv[]){
  75.     long     num_lines;
  76.     char     caller[85];
  77.     memset(caller,'\0',85);
  78.     Readfile("PCBOARD.DAT",caller,30);
  79.     strcat(caller,getenv("PCBNODE"));
  80.     parse_args(argc,argv);
  81.     set_date_time();
  82.     process_args(argc,argv);
  83.     open_wfile(caller);
  84.  
  85. }